package com.cyj.dream.auth.handler;


import com.cyj.dream.auth.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description: 暂无权限相关处理类
 * @BelongsProject: DreamChardonnay
 * @BelongsPackage: com.cyj.dream.gateway.handler
 * @Author: ChenYongJia
 * @CreateTime: 2021-10-08 13:03
 * @Email: chen87647213@163.com
 * @Version: 1.0
 */
@Slf4j
@Component
public class UserAuthAccessDeniedHandler implements AccessDeniedHandler {

    /**
     * 暂无权限返回结果
     *
     * @Author ChenYongJia
     * @CreateTime 2020-5-11 09:48:01
     */
    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException exception) {
        log.info("-----------暂无权限返回结果-----------");
        ResultUtil.responseJson(response, ResultUtil.resultCode(403, "尚未授权，如有需要请联系管理员！"));
    }

}
